// Copyright (c) 2008, 
// Marc Speck, http://www.faindu.com
// All Rights Reserved. The following is Source Code and is subject to all restrictions 
// on such code as contained in the license accompanying this product.
package com.faindu.editImage.base
{
import com.faindu.editImage.EditImage;

import flash.display.Sprite;

/**
 * <code>BaseTool</code> contains everything that is comon accross all tools such as <code>CropTool</code>.
 */
public class BaseTool extends Sprite implements IBaseTool
{
	//--------------------------------------------------------------------------
    //
    //  Constants
    //
    //--------------------------------------------------------------------------		
	/** @private */
	public static const TOP_LEFT:String = 		"topLeft";
	/** @private */
	public static const TOP:String = 			"top";
	/** @private */
	public static const TOP_RIGHT:String = 		"topRight";
	/** @private */
	public static const RIGHT:String = 			"right";
	/** @private */
	public static const BOTTOM_RIGHT:String = 	"bottomRight";
	/** @private */
	public static const BOTTOM:String = 		"bottom";
	/** @private */
	public static const BOTTOM_LEFT:String = 	"bottomLeft";
	/** @private */
	public static const LEFT:String = 			"left";

    //-------------------------------------------------------------------------- 
    //
    //  Properties
    //
    //--------------------------------------------------------------------------  	
	/**
	 * Reference to current editImage instance.
	 */
	protected var editImageTools: IEditImageTools
		
    //----------------------------------
	//  Enabled
	//----------------------------------		
	/** @private */
	protected var _enabled:Boolean;	
	/**
	 * @inheritDoc
	 * 
	 * @see com.faindu.editImage.manipulations.ImageManipulations#disableAllTools()
	 * @default false
	 */
	public function get enabled():Boolean 
	{
		return _enabled
	}
	public function set enabled( value:Boolean):void 
	{
		if (_enabled != value) 
		{
			_enabled = value
			if ( editImageTools )
				editImageTools.updateToolsEnabled()
		}
	}

    //-------------------------------------------------------------------------- 
    //
    //  Methods
    //
    //--------------------------------------------------------------------------  		
	/**
	 * Initiate the tool. <code>init</code> adds event listeners, controls to the display list
	 * and initiates all controls.
	 * 
	 * @param editImage the instance of the EditImage.
	 * @param startInteractionHandler a reference to the startInteractionHandler in the instance of EditImage.
	 * 
	 * @see com.faindu.editImage.EditImage.startInteractionHandler()
	 */
	public function init( editImage:EditImage, startInteractionHandler:Function ): void
	{
	}
	
	/**
	 * When the user clicks on a control, <code>startControlInteraction</code> is called.
	 * Setup all variables that need to be stored at the beginning of an interaction.
	 * 
	 * @internal Override this method in the tool implementation.
	 */
	protected function startControlInteraction( event:EditImageEvent ): void
	{
	}
	
	/**
	 * Reset the tool.
	 */
	public function reset(): void
	{
	}
	
	/**
	 * Draw all the controls.
	 */
	public function draw(): void
	{
	}
}
}